<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
//$api=app(\Dingo\Api\Facade\Route::class);
$api = app(\Dingo\Api\Routing\Router::class);
//测试
//$api->version('v1', function ($api) {
//    $api->get('version', function () {
//        return 'v1';
//    });
//});
//dd(110);

//新闻类的接口
//dd($api);
$api ->version('v1', ['namespace' => '\App\Http\Controllers\Api'], function ($api) {
    $api->group(['middleware'=>'api.throttle','limit'=>100,'expires'=>1],function ($api){
    $api->get('singleNews/{id}', 'NewsController@singleNews');
    $api->get('news/{classify?}', 'NewsController@news');
    $api->get('classify','ClassifyController@classify');
    $api->post('login','UserController@login');
    $api->get('logout','UserController@logout');
    $api->get('me','UserController@me');
    });
});

